package omm.domain.evolutiongraph;

import java.util.Map;
import java.util.TreeMap;

import org.joda.time.DateTime;
import org.joda.time.DateTimeComparator;

public class CalendarAnualByMonthPeriodStrategy extends AnualPeriodStrategy {

	final private Integer periods;
	final private Integer year;
	final private DateTime end;

	public CalendarAnualByMonthPeriodStrategy(int canvasWidth, DateTime end) {
		super(canvasWidth);
		//DateTime actualTime = new DateTime(System.currentTimeMillis());
		this.periods = end.getMonthOfYear();
		this.year = end.getYear();
		this.end = end;
//		Harcodeo si tengo una base vieja
//		this.periods = 8;
//		this.year = 2011;
		
	}
	
	@Override
	public Map<DateTime, Double> calculatePeriods() {
		Map<DateTime, Double> periodsBars = new TreeMap<DateTime, Double>(
				DateTimeComparator.getDateOnlyInstance());
		// Carga de fechas
		for (int month = 1; month <= periods; month++) {
			DateTime itTime = new DateTime(year, month, 1, 0, 0, 0); //Hora 00:00:00 del dia primero del mes
			periodsBars.put(itTime, 0.0);
		}
		return periodsBars;
	}

	@Override
	protected Integer getPeriodsQuantity() {
		return periods;
	}

	@Override
	public String getTitle() {
		return "por año calendario";
	}

	@Override
	public DateTime getBegin() {
		return new DateTime(end.getYear(),1,1,0,0,0);
	}

	@Override
	public DateTime getEnd() {
		return end;
	}
	
	
}
